package com.cc.factory2;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import com.cc.entity.User;

public class Test02 {
    public static void main(String[] args) {
        ApplicationContext ctx = new FileSystemXmlApplicationContext("classpath:beans.xml");
        // 一、get/set注入
        User user = (User) ctx.getBean("user");
        System.out.println("user==>" + user.show());
        // 二、构造方法注入
        // 参数类型
        User userCon01 = (User) ctx.getBean("userCon01");
        System.out.println(userCon01);

        // 参数下标
        User userCon02 = (User) ctx.getBean("userCon02");
        System.out.println(userCon02);

        // 参数名称
        User userCon03 = (User) ctx.getBean("userCon03");
        System.out.println(userCon03);
        //三、命名空间注入
        User userP = (User) ctx.getBean("userP");
        System.out.println(userP);
        
      //四、通过SpEL:属性的注入
        User userSp = (User) ctx.getBean("userSp");
        System.out.println(userSp);
        
        User userSp2 = (User) ctx.getBean("userSp2");
        System.out.println(userSp2);
        
    }
}
